<?php

/**
 *      [Discuz!] (C)2001-2099 Comsenz Inc.
 *      This is NOT a freeware, use is subject to license terms
pre_common_usergroup_field 会员用户组权限表

groupid, smallint, 会员组id,
readaccess, tinyint, 阅读权限,
allowpost, tinyint, 允许发帖,
allowreply, tinyint, 允许回复,
allowpostpoll, tinyint, 允许发表投票,
allowpostreward, tinyint, 允许发表悬赏,
allowposttrade, tinyint, 允许发表交易,
allowpostactivity, tinyint, 允许发表活动,
allowdirectpost, tinyint, 是否需要审核,
allowgetattach, tinyint, 允许下载附件,
allowgetimage, tinyint, 允许查看图片,
allowpostattach, tinyint, 允许上传附件,
allowpostimage, tinyint, 允许上传图片,
allowvote, tinyint, 允许参与投票,
allowsearch, tinyint, 允许搜索,
allowcstatus, tinyint, 允许自定义头衔,
allowinvisible, tinyint, 允许隐身登录,
allowtransfer, tinyint, 允许积分转帐,
allowsetreadperm, tinyint, 允许设置阅读权限,
allowsetattachperm, tinyint, 允许设置附件权限,
allowposttag, tinyint, 允许使用标签,
allowhidecode, tinyint, 允许使用hide代码,
allowhtml, tinyint, 允许使用html,
allowanonymous, tinyint, 允许匿名发帖,
allowsigbbcode, tinyint, 允许签名使用bbcode,
allowsigimgcode, tinyint, 允许使用img,
allowmagics, tinyint, 允许使用道具,
disableperiodctrl, tinyint, 不受时间段限制,
reasonpm, tinyint, 操作理由短信通知作者,
maxprice, smallint, 主题最大售价,
maxsigsize, smallint, 最大签名尺寸,
maxattachsize, int, 最大附件尺寸,
maxsizeperday, int, 每天最大附件总尺寸,
maxthreadsperhour, tinyint, 每小时发主题数限制,
maxpostsperhour, tinyint, 每小时发回帖数限制,
attachextensions, char, 允许发表的附件类型,
raterange, char, 评分范围,
loginreward, char, 每日打卡奖励,
mintradeprice, smallint, 交易最小积分,
maxtradeprice, smallint, 交易最大积分,
minrewardprice, smallint, 悬赏最小积分,
maxrewardprice, smallint, 悬赏最大积分,
magicsdiscount, tinyint, 道具折扣,
maxmagicsweight, smallint, 道具负载最大值,
allowpostdebate, tinyint, 允许发表辩论,
tradestick, tinyint, 可商品推荐数,
exempt, tinyint, 用户组表达式,
 0发短消息不扣积分:1
1 搜索不扣积分:2
2 下载附件不扣积分:3
3 可直接下载收费附件:4
4 可直接查看收费主题:5

maxattachnum, smallint, 最大每天附件数量,
allowposturl, tinyint, 是否允许发送含 url 内容,
allowrecommend, tinyint, 是否允许评价主题,
allowpostrushreply, TINYINT, 允许发表抢楼帖,
maxfriendnum, smallint, 最多好友数,
maxspacesize, int, 空间大小,
allowcomment, tinyint, 发表留言/评论,
allowcommentarticle, smallint, 发表文章的评论,
searchinterval, smallint, 两次搜索操作间隔,
searchignore, tinyint, 是否免费搜索,
allowblog, tinyint, 发表日志,
allowdoing, tinyint, 发表记录,
allowupload, tinyint, 上传图片,
allowshare, tinyint, 发布分享,
allowblogmod, tinyint, 发表日志需要审核,
allowdoingmod, tinyint, 发表记录需要审核,
allowuploadmod, tinyint, 上传图片需要审核,
allowsharemod, tinyint, 发布分享需要审核,
allowcss, tinyint, 允许自定义CSS,
allowpoke, tinyint, 允许打招呼,
allowfriend, tinyint, 允许加好友,
allowclick, tinyint, 允许表态,
allowmagic, tinyint, 允许使用道具,
allowstat, tinyint, 允许查看趋势统计,
allowstatdata, tinyint, 允许查看统计数据报表,
videophotoignore, tinyint, 视频认证限制,
allowviewvideophoto, tinyint, 允许查看视频认证,
allowmyop, tinyint, 允许使用应用,
magicdiscount, tinyint, 购买道具折扣,
domainlength, smallint, 二级域名最短长度,
seccode, tinyint, 发布操作需填验证码,
disablepostctrl, tinyint, 发表是否受防灌水限制,
allowbuildgroup, tinyint, 是否允许建立群组，0为不允许,
allowgroupdirectpost, tinyint, 是否允许直接在群组中发帖,
allowgroupposturl, tinyint, 是否允许在群组中发站外URL,
edittimelimit, smallint, 编辑帖子时间限制,
allowpostarticle, tinyint, 允许发布文章,
allowdownlocalimg, tinyint, 允许下载本地图片,
allowdownremoteimg, tinyint, 允许下载远程图片,
allowpostarticlemod, tinyint, 发布文章是否需要审核,
allowspacediyhtml, tinyint, 允许自定义模块使用HTML,
allowspacediybbcode, tinyint, 允许自定义模块使用BBCODE,
allowspacediyimgcode, tinyint, 允许自定义模块使用[img],
allowcommentpost, tinyint, 允许帖子点评 0:禁止 1:楼主 2:回复 3:All,
allowcommentitem, tinyint, 允许发表点评观点,
allowcommentreply, tinyint, 允许发表回复点评,
allowreplycredit, tinyint, 允许设置回帖奖励,
ignorecensor, tinyint, 是否忽略要审核的关键字,
allowsendallpm, tinyint, 是否不受“只接收好友短消息”设置的限制,
allowsendpmmaxnum, smallint, 24小时内允许发短消息的数量,
maximagesize, mediumint, 相册中允许最大图片大小,
allowmediacode, tinyint, 允许使用多媒体代码,
allowbegincode, tinyint, 允许使用开头动画代码,
allowat, smallint, 允许@用户 0：禁止 n:发帖时@的数量,
allowsetpublishdate, tinyint, 允许定时发布主题,
allowfollowcollection, tinyint, 允许关注淘专辑数,
allowcommentcollection, tinyint, 允许评论淘专辑,
allowcreatecollection, smallint, 允许创建淘专辑数,
forcesecques, tinyint, 强制设置安全提问才能进入后台管理,
forcelogin, tinyint, 强制登录方式,
closead, tinyint, 是否展示广告,
buildgroupcredits, smallint, 创建群组需要消耗的积分,
allowimgcontent, tinyint, 允许主题内容生成图片,
 *      $Id: table_common_usergroup_field.php 28041 2012-02-21 07:33:55Z chenmengshu $
 */

if(!defined('IN_DISCUZ')) {
	exit('Access Denied');
}

class table_common_usergroup_field extends discuz_table
{
	public function __construct() {

		$this->_table = 'common_usergroup_field';
		$this->_pk    = 'groupid';

		parent::__construct();
	}

	public function fetch_readaccess_by_readaccess($readaccess) {
		return DB::fetch_all('SELECT groupid,readaccess FROM %t WHERE readaccess>%d ORDER BY readaccess', array($this->_table, $readaccess), $this->_pk);
	}

	public function fetch_all_fields($gid, $fields) {
		if(!is_array($fields) || !$fields) {
			return null;
		}
		foreach($fields as &$field) {
			$field = DB::quote_field($field);
		}
		$fieldssql = implode(',', $fields);
		return DB::fetch_all('SELECT %i FROM %t %i', array($fieldssql, $this->_table, ($gid ? 'WHERE '.DB::field('groupid', $gid) : '')), $this->_pk);
	}

	public function count_by_field($field, $val, $glue = '=') {
		$allowedfield = array('allowposttrade');
		if(!in_array($field, $allowedfield)) {
			return null;
		}
		return DB::result_first('SELECT count(*) FROM %t WHERE %i', array($this->_table, DB::field($field, $val, $glue)));
	}

	public function fetch_table_struct($result = 'FIELD') {
		$datas = array();
		$query = DB::query('DESCRIBE %t', array($this->_table));
		while($data = DB::fetch($query)) {
			$datas[$data['Field']] = $result == 'FIELD' ? $data['Field'] : $data;
		}
		return $datas;
	}

	public function update_allowsearch() {
		return DB::query('UPDATE %t SET allowsearch = allowsearch | 2 WHERE groupid < 20 AND groupid NOT IN (5, 6)', array($this->_table));
	}

}

?>